home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac-Source 1994 July
/
Mac-Source_July_1994.iso
/
C and C++
/
Libraries
/
usr (gcc 1.37 libs)
/
mac
/
math.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-12-08
|
797b
|
45 lines
#include "crtlocal.h"
/* modf() returns the fractional part of value and stores the
integral part indirectly through iptr. Thus the argument
value and the returned values modf() and *iptr satisfy
(*iptr + modf) == value
and both results have the same sign as value. The defini-
tion of modf() varies among UNIX system implementations, so
avoid modf() in portable code.
*/
double modf(double value, double *iptr)
{
long x = (int) value;
if (x >= 0)
{
if (value < (double)x) x--;
}
else
{
if (value > (double)x) x++;
}
*iptr = x;
return value - *iptr;
}
int isinf(double x)
{
return 0;
}
int isnan(double x)
{
return 0;
}
double ldexp(double x, int n)
{
while (n-- > 0) x *= 2;
while (++n < 0) x /= 2;
return x;
}